﻿using Core.Domain.Entities;
using Core.Migrations.Extensions;
using FluentMigrator;

namespace Infrastructure.Persistence.Migrations.Tenants;

[Migration(202511042113)]
public class CreateTableForTenantPermission : ForwardOnlyMigration
{
    public override void Up()
    {
        MigrationExpressions.CreateTableAuditableEntityFor<TenantPermission>(Create, SchemaNames.Identity);

        Alter.Table(typeof(TenantPermission).GetTableName())
         .InSchema(SchemaNames.Identity).AddColumn("TenantId").AsString(100).Nullable().WithColumnDescription("租户标识")
         .AddColumn(MigrationExpressions.ColumnNameFor<TenantPermission>(nameof(TenantPermission.BoilerplateTenantInfoId))).AsString(100).Nullable().WithColumnDescription("关联的租户ID")
         .AddColumn(MigrationExpressions.ColumnNameFor<TenantPermission>(nameof(TenantPermission.PermissionId))).AsGuid().Nullable().WithColumnDescription("权限ID")
         .AddColumn(MigrationExpressions.ColumnNameFor<TenantPermission>(nameof(TenantPermission.AssignmentBatchId))).AsGuid().Nullable().WithColumnDescription("分配批次号");
    }
}
